//Stephen Kirksharian
//Robert Harkreader
//CPSC 321
//DUE 4/27/08

`define RTYPE 6'b000000

//We defined the difference between the Shift data
//and the ALUDATA

//funct codes
`define SLL 6'b000000
`define SRL 6'b000010
`define SRA 6'b000011
//OP-CODE
`define JAL 6'b000011 
`define LUI 6'b001111
`define LB  6'b100000
`define LW  6'b100011

//Signals sent
`define ALUdata  3'b000
`define PCdata   3'b011
`define Memdata  3'b001
`define LUIdata  3'b100
`define Shftdata 3'b010

module MemtoReg_ctr(opcodes,funct,control);

	input [5:0] opcodes,funct;
	output [2:0] control;
	reg [2:0] control;

always @(opcodes or funct) begin
	if(opcodes==`RTYPE) begin
	case(funct)
	  `SLL: control=`Shftdata;
	  `SRL: control=`Shftdata;
	  `SRA: control=`Shftdata;
	  default: control=`ALUdata;
	endcase
	end else begin
	case(opcodes)
	  `JAL: control=`PCdata;
	  `LUI: control=`LUIdata;
	  `LB:  control=`Memdata;
	  `LW:  control=`Memdata;
	   default: control=`ALUdata;
	endcase
	end
end
endmodule